package com.czh.subject.infra.basic.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.czh.subject.infra.basic.mapper.SubjectInfoMapper;
import com.czh.subject.infra.basic.entity.SubjectInfo;
import com.czh.subject.infra.basic.service.SubjectInfoService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import java.util.List;
import lombok.RequiredArgsConstructor;
/**
 * 题目信息表(SubjectInfo)表服务实现类
 *
 * @author caozaihui
 * @since 2024-07-31 00:05:23
 */
@Service("subjectInfoService")
@RequiredArgsConstructor
@Log4j2
public class SubjectInfoServiceImpl extends ServiceImpl<SubjectInfoMapper, SubjectInfo> implements SubjectInfoService {

        /** 
         * 
         * @param  id 主键
         * @author caozaihui  
         * @description //TODO  通过ID查询单条数据
         * @date 2024-07-31 00:05:23
         * @return 实例对象
         */
        @Override
        public SubjectInfo selectSubjectInfoById (Long id) {
                LambdaQueryWrapper<SubjectInfo> subjectInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
                subjectInfoLambdaQueryWrapper.eq(SubjectInfo ::getId ,id);
                return baseMapper.selectOne(subjectInfoLambdaQueryWrapper);
        }
        
        /**
         * @param subjectInfo 实例对象
         * @param categoryId
         * @param labelId
         * @param start
         * @param pageSize
         * @return 实例对象
         * @author caozaihui
         * @description //TODO  分页查询数据
         * @date 2024-07-31 00:05:23
         */
        @Override
        public List<SubjectInfo> querySubjectInfoList(SubjectInfo subjectInfo, Long categoryId, Long labelId, int start, Integer pageSize) {
            return baseMapper.querySubjectInfoList( subjectInfo,  categoryId, labelId, start,pageSize);
        }
        
        /** 
         * 
         * @param subjectInfo 实例对象
         * @author caozaihui  
         * @description //TODO  新增数据
         * @date 2024-07-31 00:05:23
         * @return 实例对象
         */
        @Override
        public int insert(SubjectInfo subjectInfo) {
               return baseMapper.insert(subjectInfo);
        }
        
        
        /** 
         * 
         * @param subjectInfo 实例对象
         * @author caozaihui  
         * @description //TODO  修改数据并返回
         * @date 2024-07-31 00:05:23
         * @return 实例对象
         */
        @Override
        public int update(SubjectInfo subjectInfo) {
                return  baseMapper.updateById(subjectInfo);
        }
        
        
        /**
         *
         * @param idList 主键
         * @author caozaihui 
         * @description //TODO    通过主键删除数据
         * @date 2024-07-31 00:05:23
         * @return
         */
        @Override
        public int deleteById(List<Long> idList) {
            return baseMapper.deleteByIds(idList);
        }

        @Override
        public int countByCondition(SubjectInfo subjectInfo, Long labelId, Long categoryId) {
            return baseMapper.countByCondition( subjectInfo,  labelId,  categoryId);
        }

        @Override
        public List<SubjectInfo> querySubjectIInfoByIds(List<Long> ids) {
                return baseMapper.selectBatchIds(ids);
        }

        @Override
        public SubjectInfo getAdjoinSubject(Long subjectId,Long categoryId, Long labelId, int i) {
                return baseMapper.getAdjoinSubject(subjectId,categoryId,labelId, i);
        }

}

